<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>关于我们</title>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>
    <link rel="stylesheet" href="/static/layui-v2.6.8/layui/css/layui.css">
    <script src="/static/layui-v2.6.8/layui/layui.js"></script>
    <style>
        .layui-form-selected dl {
            z-index: 1000;
        }
    </style>
</head>

<body>
    <?php
    include "../../fun.php";
    isLogin();
    $db=conndb();
    ?>
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block" style="width:200px;">
                <?php echo select_trees(2, $db, 0, "aboutusSortId") ?>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <script id="editor" name="content" type="text/plain" style="width:1024px;height:500px;"></script>
                <script>
                    UE.getEditor('editor');
                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>
    <script>
        layui.use(['form', 'jquery'], function() {
            var form = layui.form,
                $ = layui.jquery;

            //监听提交
            form.on('submit(formDemo)', function(data) {
                // data.field为form提交的数据
                // layer.msg(JSON.stringify(data.field));
                // console.log(data.field);
                $.ajax({
                    method: "post",
                    url: "./save.php",
                    dataType: "json",
                    data: data.field,
                    success: function(res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1,
                                time: 2000
                            }, function() {
                                parent.location.href = "./index.php";
                            });
                        } else {
                            layer.msg("操作失败");
                        }
                    }
                })
                return false;
            });
        });
    </script>
</body>

</html>